package cn.kgm.core.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.time.LocalDateTime;

@Getter
@Setter
@SuperBuilder
@AllArgsConstructor
public class SysEntity<T> extends SuperEntity<T> {

    public static final String CREATE_TIME = "createTime";
    public static final String CREATE_TIME_COLUMN = "create_time";
    public static final String UPDATED_BY = "updatedBy";
    public static final String UPDATE_TIME = "updateTime";
    public static final String UPDATE_TIME_COLUMN = "update_time";
    public static final String CREATED_BY = "createdBy";
    public static final String UPDATED_BY_COLUMN = "updated_by";
    public static final String CREATED_BY_COLUMN = "created_by";
    public static final String CREATED_ORG_ID = "orgId";
    public static final String CREATED_ORG_ID_FIELD = "org_id";
    private static final long serialVersionUID = -4603650115461757622L;

    @ApiModelProperty(value = "是否删除;0,已删除&1,未删除")
    @TableField(value = "is_del")
    protected Boolean isDel;

    @ApiModelProperty(value = "备注")
    @TableField(value = "remark")
    protected String remark;

    @ApiModelProperty(value = "最后修改时间")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;

    @ApiModelProperty(value = "最后修改人ID")
    @TableField(value = "updated_by", fill = FieldFill.INSERT_UPDATE)
    protected T updatedBy;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    protected LocalDateTime createTime;

    @ApiModelProperty(value = "创建人ID")
    @TableField(value = "created_by", fill = FieldFill.INSERT)
    protected T createdBy;

    public SysEntity(T id, LocalDateTime createTime, T createdBy, LocalDateTime updateTime, T updatedBy) {
        super(id);
        this.createTime = createTime;
        this.createdBy = createdBy;
        this.updateTime = updateTime;
        this.updatedBy = updatedBy;
    }

    public SysEntity() {
    }
}
